package com.atguigu.lease.common.mybatisplus;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Configuration;

import java.util.Date;

/**
 * ClassName: MybatisMetaObjectHandler
 * Package: com.atguigu.lease.common.mybatisplus
 * Description:
 *
 * @Autor: xvyy
 * @Create: 2024/11/16 - 14:23
 * @Version: v1.0
 */
@Configuration
public class MybatisMetaObjectHandler implements MetaObjectHandler {

    //todo insertFill 和 updateFill 方法，分别用于填充创建时间和更新时间
    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date());
    }
}
